<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
             function ktnb()
				{
				if(document.fr_banggia.banggia.value.toLowerCase().lastIndexOf(".rar")==-1&&document.fr_banggia.banggia.value.toLowerCase().lastIndexOf(".zip")==-1&&document.fr_banggia.banggia.value.toLowerCase().lastIndexOf(".pdf")==-1)&&document.fr_banggia.banggia.value.toLowerCase().lastIndexOf(".doc")==-1)
					{
					alert("bảng giá phải là định dạng *.rar,*.zip,*.doc hoặc *.pdf ");
					return false;
					}
	
				}
            
            </script>

</head>

<body>
<?php
include("kn.php");
$banggia = $_FILES["banggia"]["name"];
if(isset($_POST["up"]))
{
$lenh = "insert into banggia(tenbanggia)values('$banggia')";
$kq = mysql_query($lenh);
move_uploaded_file($_FILES["banggia"]["tmp_name"],"banggia2/".$_FILES["banggia"]["name"]);
if($kq)
?>
<script>
alert('Upload thành công!');
</script>
<?php
}
?>


<form action="" method="post" enctype="multipart/form-data" name="fr_banggia" id="fr_banggia">
  <table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td align="center">Upload bảng giá</td>
    </tr>
    <tr>
      <td align="center"><label>
        <input type="file" name="banggia" id="banggia"/>
        <input type="submit" name="up" id="up" value="Upload bảng giá" onClick="return ktnb()" />
      </label></td>
    </tr>
  </table>
</form>
</body>
</html>
